<?php

/**
 * @author asdasd
 * @copyright 2010
 */
	
	/**
	*	@usage Resuelve un query teniendo en cuenta el seteo de db_settings
	*/
	function do_query($query){
		if( empty($query) ) return false;
		
		global $SQL_DATA;
		$SQL_DATA['query'] = $query;	
		@ $link = mysql_connect( $SQL_DATA['server'], $SQL_DATA['user'], $SQL_DATA['pass']);
		if($link){
			$dbcheck = mysql_select_db($SQL_DATA['db'], $link);
			if($dbcheck){
							
				$result = mysql_query($query, $link);
				if( $result ){
					$SQL_DATA['affected_rows'] = mysql_affected_rows();
					$SQL_DATA['insert_id'] = mysql_insert_id();
					if( $result === true ) return $result;
					while( $row = mysql_fetch_assoc($result) ){
						$rows[] = $row;
					}
					mysql_close($link);
					return $rows;
										
				} else {
					$SQL_DATA['error'] = mysql_error();
					mysql_close($link);
					return false;
				}				
				
			} else {
				$SQL_DATA['error'] = mysql_error();
				mysql_close($link);
			 	return false;
			}
		} else {
			$SQL_DATA['error'] = mysql_error();
			return false;
		}
		
	}
	

?>